cmake_minimum_required(VERSION 3.0)

project (TutCpp)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

file(GLOB TutCpp_SOURCES "*.cpp")
file(GLOB TutCpp_HEADERS "*.h")

set (TutCpp_INCLUDE_DIRS "")
foreach (_headerFile ${TutCpp_HEADERS})
    get_filename_component(_dir ${_headerFile} PATH)
    list (APPEND TutCpp_INCLUDE_DIRS ${_dir})
endforeach()
list(REMOVE_DUPLICATES TutCpp_INCLUDE_DIRS)

foreach (_bodyFile ${TutCpp_SOURCES})
    get_filename_component(_name ${_bodyFile} NAME_WE)
    add_executable(${_name} ${_bodyFile})
    target_include_directories(${_name} PRIVATE ${TutCpp_INCLUDE_DIRS})
endforeach()

